<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<textarea dir=ltr id="test_move_by_word"></textarea>
<div ig="log"></div>
<script>
test(function() {
    if (window.testRunner && window.internals)
        internals.settings.setEditingBehavior('win');

    var sel = window.getSelection();
    sel.empty();

    test_move_by_word.focus();
    test_move_by_word.value = 'word word word\n\n\nword\n\n\n   ';
    test_move_by_word.selectionDirection = 'none';
    test_move_by_word.selectionStart = 0;
    test_move_by_word.selectionEnd = 0;

    var wordBreaks = [5, 10, 14, 15, 16, 17, 21, 27, 27];
    for (var i = 0; i < 6; ++i) {
        var start = test_move_by_word.selectionStart;
        sel.modify('move', 'right', 'word');
        assert_equals(test_move_by_word.selectionStart, wordBreaks[i], 'word break at ' + i);
    }
});
</script>
